import { DataTypes } from 'sequelize';
import sequelize from '../config/db.config.js';

const PersonEvent = sequelize.define('PersonEvent', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    field: 'event_id'
  },
  personId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: 'persons',
      key: 'person_id'
    },
    field: 'person_id'
  },
  eventTime: {
    type: DataTypes.DATE,
    allowNull: true,
    field: 'event_time'
  },
  eventTypeId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    field: 'event_type_id'
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: true
  },
  attachment: {
    type: DataTypes.STRING,
    allowNull: true
  }
}, {
  tableName: 'person_events',
  timestamps: true,
  paranoid: true,
  deletedAt: 'deleted_at'
});

export default PersonEvent; 